import os
import os.path as p
import time
import shutil

print(os.getcwd())
# os.mkdir('os_test')  # 在D:\24_computer_z2\file_demo下新建文件夹os_test
# os.mkdir('os_test')  # 当文件已存在时，无法创建该文件。
os.chdir('D:\\24_computer_z2\\file_demo\\os_test\\mk_test')
print(os.getcwd())
# os.mkdir('mk_test')
# os.mkdir('D:\\24_computer_z2\\file_demo\\os_test\\os_test01')

# for i in range(0,10):  # 批量创建目录
#     path = 'D:\\24_computer_z2\\file_demo\\os_test\\os_test{}'.format(i)
#     print(path)
#     os.mkdir(path)

# file = open('test_01.txt','w')
# file.write('test....test...test')

# for i in range(0,10):  # 批量创建文件
#     path = 'D:\\24_computer_z2\\file_demo\\os_test\\os_test0\\test_{}.txt'.format(i)
#     print(path)
#     file1 = open(path,'w')
#     file1.write('111{}'.format(i))

# for i in range(0,10):  # 批量删除文件
#     path = 'D:\\24_computer_z2\\file_demo\\os_test\\os_test0\\test_{}'.format(i)
#     print(path)
#     os.remove(path)

os.chdir('D:\\24_computer_z2\\file_demo\\os_test\\mk_test')
print(os.getcwd())
# os.rmdir('os_test0')  # 该目录非空不能删除
# os.rmdir('os_test01')
# os.chdir('D:\\24_computer_z2\\file_demo\\os_test\\os_test1')
# os.mkdir('os_test001')
# os.chdir('D:\\24_computer_z2\\file_demo\\os_test\\os_test1\\os_test001')
# os.mkdir('os_test0001')
# os.removedirs('D:\\24_computer_z2\\file_demo\\os_test\\os_test1\\os_test001\\os_test0001')
# print(os.listdir('D:\\24_computer_z2\\file_demo'))
# print(os.listdir('D:\\24_computer_z2\\file_demo\\os_test'))
# print(os.listdir('D:\\24_computer_z2\\file_demo\\os_test\\os_test0'))  # 查看指定目录下的文件和文件夹列表
# os.rename('test_01.txt','test_02.txt')

os.chdir('D:\\24_computer_z2\\file_demo\\os_test\\os_test0')
print(os.getcwd())
# for i in range(10,20):
#     name = 'test_{}.txt'.format(i-10)
#     print(name)
#     re_name = 'test_{}.txt'.format(i)
#     print(re_name)
#     os.rename(name,re_name)

print(p.abspath('test_19.txt'))
temp = p.getatime('test_19.txt')
print(temp)
te = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(temp))
print(te)


